﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BCGC.BLL.Helper;
using BCGC.BLL.BusinessObject.Announcement;

public partial class AnnouncementDetail : PublicBasePage
{
    private int Id
    {
        get
        {
            if (ViewState["Id"] == null)
                ViewState["Id"] = 0;
            return (int)ViewState["Id"];
        }
        set { ViewState["Id"] = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id = Id = 0;
            if (!string.IsNullOrEmpty(Request.QueryString["id"]) && int.TryParse(Request.QueryString["id"], out id))
            {
                Id = id;
                LoadData();
            }
            else
                Response.Redirect(CustomSiteMap.Announcements);
        }
    }

    private void LoadData()
    {
        AnnouncementItem announcementItem = AnnouncementItem.GetAnnouncementItemById(Id);
        if (announcementItem == null)
            Response.Redirect(CustomSiteMap.Announcement);
        else
        {
            lblTitle.Text = announcementItem.Title;
            ltlDescription.Text = Server.HtmlDecode(announcementItem.Description);
            lblCreateDate.Text = announcementItem.CreateDateTime.ToString("dd/MM/yyyy");
            lblLastUpdateDate.Text = announcementItem.LastUpdateDateTime.ToString("dd/MM/yyyy");
        }
    }
}
